/**
 * 消息中心API模块
 */
import request from '../request'

export default {
  /**
   * 获取消息列表
   * @param {Object} params 查询参数 {type, status, page, limit}
   * @returns {Promise}
   */
  getMessages: (params = {}) => {
    return request({
      url: '/api/messages',
      method: 'get',
      params
    })
  },
  
  /**
   * 获取未读消息数量
   * @returns {Promise}
   */
  getUnreadCount: () => {
    return request({
      url: '/api/messages/unread/count',
      method: 'get'
    })
  },
  
  /**
   * 标记消息为已读
   * @param {Number|String} id 消息ID
   * @returns {Promise}
   */
  markAsRead: (id) => {
    return request({
      url: `/api/messages/${id}/read`,
      method: 'put'
    })
  },
  
  /**
   * 批量标记消息为已读
   * @param {Array} ids 消息ID数组
   * @returns {Promise}
   */
  batchMarkAsRead: (ids) => {
    return request({
      url: '/api/messages/batch/read',
      method: 'put',
      data: { ids }
    })
  },
  
  /**
   * 删除消息
   * @param {Number|String} id 消息ID
   * @returns {Promise}
   */
  deleteMessage: (id) => {
    return request({
      url: `/api/messages/${id}`,
      method: 'delete'
    })
  },
  
  /**
   * 批量删除消息
   * @param {Array} ids 消息ID数组
   * @returns {Promise}
   */
  batchDeleteMessages: (ids) => {
    return request({
      url: '/api/messages/batch',
      method: 'delete',
      data: { ids }
    })
  },
  
  /**
   * 获取消息详情
   * @param {Number|String} id 消息ID
   * @returns {Promise}
   */
  getMessageDetail: (id) => {
    return request({
      url: `/api/messages/${id}`,
      method: 'get'
    })
  }
} 